<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
  %>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  <meta charset="utf-8"/>
  <title>YOOUCE 补丁升级工具</title>

  <meta name="description" content="overview &amp; stats"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

  <!-- bootstrap & fontawesome -->
  <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
  <link rel="stylesheet" href="assets/css/font-awesome.min.css"/>

  <!-- page specific plugin styles -->

  <!-- text fonts -->
  <link rel="stylesheet" href="assets/css/ace-fonts.css"/>

  <!-- ace styles -->
  <link rel="stylesheet" href="assets/css/ace.min.css" id="main-ace-style"/>

  <link rel="stylesheet" href="assets/css/ace-skins.min.css"/>
  <link rel="stylesheet" href="assets/css/ace-rtl.min.css"/>


  <!-- ace settings handler -->
  <script src="assets/js/ace-extra.min.js"></script>
  <script src="assets/js/jquery-1.10.2.min.js"></script>

  <script src="assets/js/bootstrap.min.js"></script>

  <!-- page specific plugin scripts -->
  <script src="assets/js/fuelux/fuelux.wizard.min.js"></script>
  <script src="assets/js/jquery.validate.min.js"></script>
  <script src="assets/js/additional-methods.min.js"></script>
  <script src="assets/js/bootbox.min.js"></script>
  <script src="assets/js/jquery.maskedinput.min.js"></script>
  <script src="assets/js/select2.min.js"></script>

  <!-- ace scripts -->
  <script src="assets/js/ace-elements.min.js"></script>
  <script src="assets/js/ace.min.js"></script>
  <script src="assets/ajaxfileupload.js"/>
</head>

<body>
<div class="main-container" id="main-container">
  <script type="text/javascript">
    try {
      ace.settings.check('main-container', 'fixed')
    } catch (e) {
    }
  </script>

  <div class="main-content">
    <div class="page-content">
      <div class="page-content-area">
        <div class="row">
          <div class="col-xs-12">
            <div class="widget-box">
              <div class="widget-body">
                <div class="widget-main">
                  <form class="form-horizontal" id="sample-form">
                    <div class="widget-box">
                      <!-- #section:plugins/fuelux.wizard.container -->
                      <div class="step-content pos-rel" id="step-container">
                        <div class="step-pane active" id="step1">
                          <h3 class="lighter block green">设置服务器信息</h3>


                          <!-- #section:elements.form.input-state -->
                          <div class="form-group has-warning">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right">服务器IP</label>

                            <div class="col-xs-12 col-sm-5">
																<span class="block input-icon input-icon-right">
																	<input type="text" name="serverIp"
                                                                           value="192.168.1.138" class="width-100"/>
																	<i class="ace-icon fa fa-leaf"></i>
																</span>
                            </div>
                          </div>

                          <!-- /section:elements.form.input-state -->
                          <div class="form-group has-error">
                            <label class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">用户名</label>

                            <div class="col-xs-12 col-sm-5">
																<span class="block input-icon input-icon-right">
																	<input type="text" name="serverUserName"
                                                                           value="administrator" class="width-100"/>
																	<i class="ace-icon fa fa-times-circle"></i>
																</span>
                            </div>
                          </div>

                          <div class="form-group has-success">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right">密码</label>

                            <div class="col-xs-12 col-sm-5">
																<span class="block input-icon input-icon-right">
																	<input type="password" name="serverPassword"
                                                                           value="key4054826" class="width-100"/>
																	<i class="ace-icon fa fa-check-circle"></i>
																</span>
                            </div>
                          </div>

                          <div class="form-group has-info">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right">工程目录</label>

                            <div class="col-xs-12 col-sm-5">
																<span class="block input-icon input-icon-right">
																	<input type="text" name="contextPath"
                                                                           value="/home/adminidtrator/test"
                                                                           class="width-100"/>
																	<i class="ace-icon fa fa-info-circle"></i>
																</span>
                            </div>
                          </div>
                          <div class="form-group has-info">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right">工程目录</label>

                            <div class="col-xs-12 col-sm-5">
																<span class="block input-icon input-icon-right">
																	<input type="text" name="contextPath"
                                                                           value="/home/adminidtrator/test"
                                                                           class="width-100"/>
																	<i class="ace-icon fa fa-info-circle"></i>
																</span>
                            </div>
                          </div>
                          <div class="form-group has-info">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right">选择补丁</label>

                            <div class="col-xs-12 col-sm-5">
																<span class="block input-icon input-icon-right">
																	<input type="text" name="contextPath"
                                                                           value="/home/adminidtrator/test"
                                                                           class="width-100"/>
																	<i class="ace-icon fa fa-info-circle"></i>
																</span>
                            </div>
                          </div>
                          <div class="form-group has-info">
                            <label class="col-xs-12 col-sm-3 control-label no-padding-right"></label>
                            <div class="col-xs-12 col-sm-5" align="center">

																<span class="block input-icon input-icon-right" >
																	<input class="btn btn-success" type="submit" name="升级" />
																	<input class="btn btn-success" type="submit" name="返回" />
																</span>
                            </div>
                          </div>

                        </div>
                      </div>
                    </div>



                  </form>
                </div>
                <!-- /.widget-main -->
              </div>
              <!-- /.widget-body -->
            </div>


          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.page-content-area -->
    </div>
    <!-- /.page-content -->
  </div>
  <!-- /.main-content -->


</div>

</body>

<script type="text/javascript">

  iframeHeight();
  //iframe 父窗体自适应高度
  function iframeHeight() {
    var ifm = window.parent.document.getElementById("mainFrame");
    if (ifm != null) {
      ifm.height = $("body").height();
    }
  }

  function ajaxFileUpload() {
    //执行上传文件操作的函数，使用encodeURI方法，防止传输中文字符的时候出现乱码
    var uploadUrl = '/uploadPatchFile';
    $.ajaxFileUpload({
      //处理文件上传操作的服务器端地址
      url: uploadUrl,
      secureuri: false,                       //是否启用安全提交,默认为false
      fileElementId: 'uploadFileInput',           //文件选择框的id属性
      dataType: 'text',                       //服务器返回的格式,可以是json或xml等
      success: function (data, status) {        //服务器响应成功时的处理函数
        data = data.replace("<PRE>", '');  //ajaxFileUpload会对服务器响应回来的text内容加上<pre>text</pre>前后缀
        data = data.replace("</PRE>", '');
        data = data.replace("<pre>", '');
        data = data.replace("</pre>", ''); //本例中设定上传文件完毕后,服务端会返回给前台[0`filepath]

        //将String字符串转换成json
        var dataset = $.parseJSON(data);
        if (dataset.status == "OK") {
          alert(dataset.realPath);
          $("input[name='realPath']").val(dataset.realPath);
          alert("上传成功");
        } else if (dataset.status == "Empty") {
          alert("没有选择文件！");
        } else {
          alert('上传失败，请重试！！');
        }
      },
      error: function (data, status, e) { //服务器响应失败时的处理函数
        console.log(e);
        console.log(data);
        alert('上传失败，请重试！！');
      }
    });
  }
</script>
